[Golang][client] fix RFC-3339 date-time query param #325
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
PR checklist
./bin/
to update Petstore sample so that CIs can verify the change. (For instance, only need to run./bin/{LANG}-petstore.sh
and./bin/security/{LANG}-petstore.sh
if updating the {LANG} (e.g. php, ruby, python, etc) code generator or {LANG} client's mustache templates). Windows batch files can be found in.\bin\windows\
.master
,3.1.x
,4.0.x
. Default:master
.@antihax
@bvwells
Description of the PR
The OpenAPI 3.0 Spec and Swagger 2.0 Spec define the
date-time
string format as:An example of RFC-3339
date-time
format is2017-07-21T17:32:28Z
. Here is the full spec:The current SDK will create in an incorrectly formatted time for a
query
parameter. This happens becauseclient.go
parameterToString
function usesfmt.Sprintf("%v", obj)
which produces the following time format which is not a RFC-3339 time:2018-01-01 00:00:00 +0000 UTC
This can be resolved by adding the following code to
parameterToString(obj interface{}, collectionFormat string) string
.This approach for testing time has been verified to work and is mentioned here:
https://stackoverflow.com/questions/41483505/golang-check-if-a-data-is-time-time
An example is on Go Playground here: https://play.golang.org/p/Jq16Shapio8
A test is not provided because it appears a
date-time
formatstring
query
parameter does not exist in the current Petstore API.This is a breaking change since the date time format produced by the Client SDK changes.
More info can be seen here where the issue was encountered:
client.MessagesApi.ListMessages
Parameter [dateFrom] value is invalid grokify/go-ringcentral-client#19date-time
query parameter does not produce a RFC 3339 time per spec definition swagger-api/swagger-codegen#8039This PR updates
client.mustache
. Other changed files are from a re-builtgo-petstore
SDK in the sample folder.